package org.itboys.mobile.service.mongo.weixin;


import org.apache.commons.lang3.StringUtils;
import org.itboys.commons.utils.tools.ListUtil;
import org.itboys.commons.utils.tools.LongUtil;
import org.itboys.framework.resource.ResourceHolder;
import org.itboys.mobile.common.SundayCommonConstants;
import org.itboys.mobile.dto.project.ZhongBaoProjectDto;
import org.itboys.mobile.entity.ZhongBaoTag;
import org.itboys.mobile.entity.mongo.SundayMember;
import org.itboys.mobile.entity.mongo.ZhongBaoChat;
import org.itboys.mobile.entity.mongo.ZhongBaoChatGroup;
import org.itboys.mobile.entity.mongo.ZhongBaoMessage;
import org.itboys.mobile.entity.mongo.project.*;
import org.itboys.mongodb.core.MongoDataSource;
import org.itboys.mongodb.service.BaseMongoService;
import org.itboys.param.ParamUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sun.security.provider.Sun;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * 作者：jiangxiong
 * 日期：2017年5月8日
 * 联系方式 ：empty90911@126.com
 * 描述：众包_微信_项目_service
 */
@Service
public class ZhongBaoWeiXinProjectService extends BaseMongoService<ZhongBaoProject> {

    @Autowired
    private SundayWeiXinMemberService memberService;
    @Autowired
    private ZhongBaoWeiXinProjectImageService projectImageService;
    @Autowired
    private ZhongBaoWeiXinProjectEmployeeService projectEmployeeService;
    @Autowired
    private ZhongBaoWeiXinProjectInfoService projectInfoService;
    @Autowired
    private ZhongBaoWeiXinMessageService messageService;
    @Autowired
    private ZhongBaoWeiXinProjectSignService projectSignService;
    @Autowired
    private ZhongBaoWeiXinChatGroupService chatGroupService;
    @Autowired
    private ZhongBaoWeiXinChatService chatService;
    @Autowired
    private ZhongBaoWeiXinTagService tagService;
    @Autowired
    private ResourceHolder resourceHolder;



    @Resource(name = "mobileDs")
    private MongoDataSource mobileDataSource;
    @Override
    protected MongoDataSource getMongoDataSource() {
        return mobileDataSource;
    }

    @Override
    protected Class<ZhongBaoProject> getEntityClass() {
        return ZhongBaoProject.class;
    }


    /**
     * 新增项目
     * @param id
     * @param memberId
     * @param name
     * @param keyWords
     * @param startDate
     * @param endDate
     * @param desc
     * @param images
     * @param employeeIds
     */
    public Long addProject(long id, Long memberId, String name, String keyWords, Date startDate, Date endDate, String desc,Integer type, List<String> images,List<Long> employeeIds,
                           //标签的信息
                           String trade, Long provinceId, String provinceName, Long cityId, String cityName, String name1, String name2, String name3
                           ){
            ZhongBaoProject project= new ZhongBaoProject();
             SundayMember member =memberService.getById(memberId);
             project.setId(id);
             project.setMemberId(memberId);
             project.setMemberName(member.getNickName());
             project.setMemberMobile(member.getMobile());

             project.setName(name);
             project.setKeyWords(keyWords);
             project.setStartDate(startDate);
             project.setEndDate(endDate);
             project.setDesc(desc);
             project.setType(type);
             project.setStatus(SundayCommonConstants.zhongbao_project_status_ysh);
            boolean isNeedHandle=false;
            //用户为商户且为员工身份时，需要开启审核
            if(member.getUserType()==SundayCommonConstants.user_type_business&&
                    LongUtil.isNotZreo(member.getParentId())){
                    project.setStatus(SundayCommonConstants.zhongbao_project_status_dsh);
                 isNeedHandle=true;
            }
            super.save(project);
            //保存图片
            projectImageService.saveImages(project.getId(),images);
            //保存员工
            projectEmployeeService.saveEmployees(project.getId(),employeeIds);
            //创建标签
            tagService.saveTag(0l,  project.getId(),  trade,  provinceId,  provinceName,  cityId,  cityName,  name1,  name2,  name3);

            logger.info("项目是否需要审核；"+isNeedHandle);
            //需要审核
            if(isNeedHandle){
                logger.info("项目审核");
                //创建审核消息
                super.update(project.getId(),"handlerId",member.getParentId());
                messageService.generateMessage(member.getParentId(),memberId,project.getId(),SundayCommonConstants.zhongbao_message_type_apply,project.getName(),project.getDesc(),project.getId(),null);
            //不需要审核
            }else{
                logger.info("项目不审核");
                //根据项目标签创建消息通知
                //创建聊天组。发布人和员工
                String memberIdStrs ="";
                List<Long> memberIds = new ArrayList<>();
                memberIdStrs+=String.valueOf(memberId)+",";
                memberIds.add(memberId);
                for(Long employeeId:employeeIds){
                    memberIdStrs+=String.valueOf(employeeId)+",";
                    memberIds.add(employeeId);
                }
                memberIdStrs=memberIdStrs.substring(0,memberIdStrs.length()-1);

                long chatGroupId=chatGroupService.generateGroup(null,null,project.getId(),memberIdStrs);
                logger.info("----------聊天组ID"+chatGroupId);
                super.update(project.getId(),"chatGroupId",chatGroupId);
                //发布人和业务员自动关注和报名
                autoOperate(memberIds,project.getId());
                //2018年1月16日，发布消息通知
                notice(project.getId(),project.getName(),project.getMemberId());
                //2018年1月18日，发布通知消息给员工
                noticeEmployee(project.getId(),project.getName(),project.getMemberId(),employeeIds);
            }
            return project.getId();
    }

    /**
     * 项目审核
     * @param id
     * @param memberId
     * @param name
     * @param keyWords
     * @param startDate
     * @param endDate
     * @param desc
     * @param type
     * @param images
     * @param employeeIds
     */

    public Long handle(long id, Long memberId, String name,
                       String keyWords, Date startDate, Date endDate,
                       String desc,Integer type, List<String> images,
                       List<Long> employeeIds,boolean isAgree,
                      //标签的信息
                      String trade, Long provinceId, String provinceName, Long cityId, String cityName, String name1, String name2, String name3
){
       // ZhongBaoProject project= super.getById(id);
        //驳回项目
        ZhongBaoProject project= super.getById(id);
        if(!isAgree){
          //  ZhongBaoProject project= super.getById(id);
         //   project.setStatus(SundayCommonConstants.zhongbao_project_status_ybh);
            super.update(id,"status",SundayCommonConstants.zhongbao_project_sign_ybh);
            //创建审核驳回消息
            messageService.generateMessage(project.getMemberId(),memberId,id,SundayCommonConstants.zhongbao_message_type_refuse,"项目【"+name+"】申请申请被驳回,","项目【"+name+"】申请申请被驳回",id,null);
        }else{
            SundayMember member =memberService.getById(project.getMemberId());
            project.setId(id);
            project.setMemberId(project.getMemberId());
            project.setMemberName(member.getNickName());
            project.setMemberMobile(member.getMobile());
            project.setName(name);
            project.setKeyWords(keyWords);
            project.setStartDate(startDate);
            project.setEndDate(endDate);
            project.setDesc(desc);
            project.setType(type);
            project.setStatus(SundayCommonConstants.zhongbao_project_status_ysh);
            super.updateExceptEmpty(id,project);
            //保存图片
            projectImageService.saveImages(project.getId(),images);
            //保存员工
            projectEmployeeService.saveEmployees(project.getId(),employeeIds);
            //创建标签
            tagService.saveTag(0l,  project.getId(),  trade,  provinceId,  provinceName,  cityId,  cityName,  name1,  name2,  name3);
            //创建审核通过消息通知
            messageService.generateMessage(project.getMemberId(),memberId,project.getId(),SundayCommonConstants.zhongbao_message_type_pass,project.getName()+"审核通过",project.getName()+"审核通过",project.getId(),null);

            //根据项目标签创建消息通知
            //创建聊天组。发布人和员工
            String memberIdStrs ="";
            List<Long> memberIds = new ArrayList<>();
            memberIdStrs+=String.valueOf(project.getMemberId())+",";
            memberIds.add(project.getMemberId());
            for(Long employeeId:employeeIds){
                memberIdStrs+=String.valueOf(employeeId)+",";
                memberIds.add(employeeId);
            }
            memberIdStrs=memberIdStrs.substring(0,memberIdStrs.length()-1);

            long chatGroupId=chatGroupService.generateGroup(null,null,project.getId(),memberIdStrs);
            logger.info("----------聊天组ID"+chatGroupId);
            if(LongUtil.isNotZreo(chatGroupId)){
                super.update(project.getId(),"chatGroupId",chatGroupId);
            }
            //发布人和业务员自动关注和报名
            autoOperate(memberIds,project.getId());
            //2018年1月16日，发布消息通知
            notice(project.getId(),project.getName(),project.getMemberId());
            //2018年1月18日，发布通知消息给员工
            noticeEmployee(project.getId(),project.getName(),project.getMemberId(),employeeIds);
        }
        //消息已读
        Map<String,Object> param = new HashMap<String,Object>();
        param.put("isDeleted",SundayCommonConstants.NO);
        param.put("status",SundayCommonConstants.NO);
        param.put("type",SundayCommonConstants.zhongbao_message_type_apply);
        List<ZhongBaoMessage> messages =messageService.list(param);
        for(ZhongBaoMessage message:messages){
            message.setStatus(SundayCommonConstants.YES);
        }
        messageService.batchUpdateWithoutLogin(messages);
        return id;
    }
    /**
     * 分页获取项目。
     * @param request
     * @param memberId
     * @param type
     * @return
     */
    public List<ZhongBaoProjectDto>  getProjects(HttpServletRequest request,Long memberId,Integer type){
        Map<String,Object> param=new HashMap<String,Object>();
        Map<String,String> containsparam= ParamUtil.packageMongoVagueParam(request,"keyWords","name");
       // List<ZhongBaoProjectDto> dtos = null;
        SundayMember member=memberService.getById(memberId);
        List<ZhongBaoProject> projects=null;
         // List<>
        //1，自己关注的项目，2团体项目，3其他项目
        param.put("isDeleted", SundayCommonConstants.NO);

        //1,自己关注的项目(即，自己关注和报名的)
        if(type==1){
            List<Long> projectIds=new ArrayList<>();
            projectIds.addAll(projectInfoService.getProjectIds(memberId,2)) ;
            projectIds.addAll(projectSignService.getProjectIds(memberId));
            param.put("id in",projectIds);

        //2,团队项目(1，个人版获取自己的项目，2企业版获取)
        }else if(type==2){
            List<Long> memberIds = new ArrayList<>();
            memberIds.add(0l);

            //判断登陆人是否是管理员且为商户
            if(member.getUserType()==SundayCommonConstants.user_type_business){
                //查询登陆人的下属或同一上级下的所有人员
                Map<String,Object> param2=new HashMap<String,Object>();
                param2.put("isDeleted",SundayCommonConstants.NO);
                param2.put("userType",SundayCommonConstants.user_type_business);
                    //管理者
                    if(LongUtil.isZreo(member.getParentId())){
                        param2.put("parentId",member.getId());
                        //自己的项目
                        memberIds.add(memberId);
                    //员工
                    }else{
                        param2.put("parentId",member.getParentId());
                        //包含员工管理者的项目
                        memberIds.add(member.getParentId());
                    }
                List<SundayMember> employees=memberService.list(param2);

                if(ListUtil.isNotNull(employees)){
                    for(SundayMember employee:employees){
                        memberIds.add(employee.getId());
                    }
                }
            //个人版
            }else if(member.getUserType()==SundayCommonConstants.user_type_person){
                 memberIds.add(memberId);
            }
        //查询项目
        param.put("memberId in",memberIds);
        //公共项目
        }else if(type==3){
            //3.1,不能获取对内项目
            param.put("type",SundayCommonConstants.zhongbao_project_public);
            //3.2,只获取已审核的项目(进行中)
            param.put("status",SundayCommonConstants.zhongbao_project_status_ysh);

           // projects=super.containpageQuery(request,containsparam,param).getData();

        }
       // if(ListUtil.isNotNull(dtos)){
        return packageMuilt(super.containpageQuery(request,containsparam,param).getData());
        //}
       // return null;
    }
    /**
     * 获取项目详情
     * @param projectId
     * @param memberId
     * @return
     */
    public ZhongBaoProjectDto  getProjectDetail(Long projectId,Long memberId){
        ZhongBaoProjectDto dto =null;
        if(LongUtil.isZreo(projectId)){
            dto= new ZhongBaoProjectDto();
            dto.setId(0l);
            return dto;
        }
        dto = packageSingle(super.getById(projectId));
        String imgRoot = resourceHolder.getStringValue("imgRoot");
        Map<String,Object> param=new HashMap<String,Object>();
        //装载项目图片
        param.put("isDeleted", SundayCommonConstants.NO);
        param.put("projectId",projectId);
        List<ZhongBaoProjectImage> images = projectImageService.list(param);
        for(ZhongBaoProjectImage image:images){
            image.setUrl(imgRoot+image.getUrl());
        }
        dto.setImages(images);
        //获取转发、关注的信息
        param.clear();
        param.put("isDeleted", SundayCommonConstants.NO);
        param.put("projectId",projectId);
        param.put("order","desc");
        param.put("sort","ct");
        List<ZhongBaoProjectInfo> infos = projectInfoService.list(param);
        for(ZhongBaoProjectInfo info:infos){
            info.setMemberImage(imgRoot+info.getMemberImage());
        }
        //校验是否转发、关注
        Integer isSpread=0;
        Integer isCollection=0;

        //不是自己发布的项目， 才校验是否转发、报名、关注
   //  if(dto.getMemberId().longValue()!=memberId.longValue()){
        for(ZhongBaoProjectInfo info:infos){

            if(LongUtil.isNotZreo(info.getMemberId())&&
                    info.getMemberId().longValue()==memberId.longValue()){
                if(info.getType()==SundayCommonConstants.zhongbao_project_info_spread){
                    isSpread=1;
                }

                if(info.getType()==SundayCommonConstants.zhongbao_project_info_collection){
                    isCollection=1;
                }
            }
        }

        dto.setIsSpread(isSpread);
        dto.setIsCollection(isCollection);
        //校验是否报名0否1是2审核中
        Integer isSign=  projectSignService.check(projectId,memberId);;
        dto.setIsSign(isSign);


        //获取转发、关注的人员信息。项目详情中就各自取5条
        List<ZhongBaoProjectInfo> spreads = new ArrayList<>();

        List<ZhongBaoProjectInfo> collections = new ArrayList<>();
        for(ZhongBaoProjectInfo info:infos){
            if(spreads.size()<=5
                    &&info.getType()==SundayCommonConstants.zhongbao_project_info_spread
                    //2017年12月25日，只查询不是系统自动操作的。
                    &&info.getIsSystem()==SundayCommonConstants.NO){
                spreads.add(info);
            }
            if(collections.size()<=5
                    &&info.getType()==SundayCommonConstants.zhongbao_project_info_collection
                    //2017年12月25日，只查询不是系统自动操作的。
                    &&info.getIsSystem()==SundayCommonConstants.NO){
                collections.add(info);
            }
        }

        dto.setSpreads(spreads);
        dto.setCollections(collections);
        //详情中获取报名信息
        param.clear();
        param.put("isDeleted", SundayCommonConstants.NO);
        param.put("projectId",projectId);
        param.put("status",SundayCommonConstants.zhongbao_project_sign_ytg);
        //2017年12月25日，只查询不是系统自动操作的。
        param.put("isSystem", SundayCommonConstants.NO);
        param.put("order","desc");
        param.put("sort","ct");
        dto.setSigns(projectSignService.list(param,5));
        //详情中标签
        ZhongBaoTag tag = tagService.getTag(0l,projectId);
        dto.setTag(tag);
        //获取项目业务员
        param.clear();
        param.put("isDeleted", SundayCommonConstants.NO);
        param.put("projectId",projectId);
        List<ZhongBaoProjectEmployee> employees = projectEmployeeService.list(param);
        for(ZhongBaoProjectEmployee employee:employees){
            employee.setMemberImage(imgRoot+employee.getMemberImage());
        }
        dto.setEmployees(employees);
        return dto;
    }
    /**
     * 组装单个dto
     * @return
     */
    public ZhongBaoProjectDto  packageSingle(ZhongBaoProject project){
        return new ZhongBaoProjectDto(project.getId(), project.getCreateTime(),project.getCreateDate(),
                project.getName(),project.getMemberId(), project.getMemberName(), project.getMemberMobile(),
                project.getDealerId(), project.getDealerName(), project.getDealerMobile(), project.getStartDate(), project.getEndDate(),
                project.getKeyWords(), project.getDesc(), project.getStatus(), project.getType(),project.getChatGroupId(),project.getHandlerId());
    }

    /**
     * 组装多个dto
     * @param projects

     * @return
     */
    public List<ZhongBaoProjectDto>  packageMuilt(List<ZhongBaoProject> projects){
        List<ZhongBaoProjectDto> dtos=new ArrayList<ZhongBaoProjectDto>();
        List<Long> projectIds=new ArrayList<>();
        for(ZhongBaoProject project:projects){
            projectIds.add(project.getId());
        }
       List<Long> chatGroupIds=new ArrayList<>();
        for(ZhongBaoProject project:projects){
            chatGroupIds.add(project.getChatGroupId());
        }
        Map<String,Object> param=new HashMap<String,Object>();
        List<ZhongBaoProjectSign> signs = new ArrayList<>();
        List<ZhongBaoChat> chats= new ArrayList<ZhongBaoChat>();
        if(ListUtil.isNotNull(projectIds)){
            param.clear();
            param.put("isDeleted", SundayCommonConstants.NO);
            param.put("projectId in",projectIds);
            signs=projectSignService.list(param);
        }
        if(ListUtil.isNotNull(chatGroupIds)){
            param.clear();
            param.put("isDeleted", SundayCommonConstants.NO);
            param.put("groupId in",chatGroupIds);
            chats=chatService.list(param);
        }

        if(ListUtil.isNull(projectIds))return dtos;
        //匹配项目消息和报名人数
        for(ZhongBaoProject project:projects){
            ZhongBaoProjectDto dto= packageSingle(project);
            dto.setIsCollection(0);
            int signNumber = 0;
            int chatNumber = 0;
            for(ZhongBaoProjectSign sign:signs){
                if(LongUtil.isNotZreo(sign.getProjectId())&&project.getId()==sign.getProjectId().longValue()){
                    signNumber++;
                }
            }
            for(ZhongBaoChat chat:chats){
                if(LongUtil.isNotZreo(chat.getGroupId())&&
                        LongUtil.isNotZreo(project.getChatGroupId())&&
                        project.getChatGroupId()==chat.getGroupId().longValue()){
                    chatNumber++;
                }
            }
            //留言数量
            dto.setChatNumber(chatNumber);
            //报名人数
            dto.setSignNumber(signNumber);
            dtos.add(dto);
        }


        return dtos;
    }
    /**
     * 删除项目图片
     */
    public void deleteProjectImage(long projectId){
        projectImageService.delete(projectId);
    }


    /**
     * 项目成交
     * @param projectId
     * @param memberId
     */
    public void dealProject(long projectId,long memberId){
        ZhongBaoProject project= super.getById(projectId);
        SundayMember member= memberService.getById(memberId);
        project.setDealerId(memberId);
        project.setDealerMobile(member.getMobile());
        project.setDealerName(member.getNickName());
        project.setStatus(SundayCommonConstants.zhongbao_project_status_ycj);
        super.updateExceptEmpty(projectId,project);
        //2018年1月14日，推送消息
        messageService.generateMessage(memberId,project.getMemberId(),project.getId(),SundayCommonConstants.zhongbao_message_type_success,project.getName()+"确认成交",project.getName()+"确认成交",project.getId(),null);

    }

    /**
     * 项目发布时，自动关注和报名。项目发布人和业务员
     * @param memberIds
     */
    public void autoOperate(List<Long> memberIds,Long projectId){

        Map<String,Object> param = new HashMap<String,Object>();
        param.put("id in",memberIds);
        List<SundayMember> members= memberService.list(param);
        //关注的
        List<ZhongBaoProjectInfo> guanzhus = new ArrayList<>();
        //报名的
        List<ZhongBaoProjectSign> signs = new ArrayList<>();

        for(SundayMember member:members){
            guanzhus.add(new ZhongBaoProjectInfo(projectId,  member.getId(), member.getNickName(), member.getMobile(), member.getImage(), null,2,SundayCommonConstants.YES));
            signs.add(new ZhongBaoProjectSign(projectId,  member.getId(), member.getNickName(), member.getMobile(), member.getImage(), "系统自动报名",2,SundayCommonConstants.YES));
        }
        projectInfoService.batchSaveWithoutLogin(guanzhus);
        projectSignService.batchSaveWithoutLogin(signs);
    }


    /**
     * 项目通知。项目发布时通知符合标签的会员
     * 1，行业和地点必须匹配
     * 2，自定义标签匹配一个
     * @param projectId
     * @param applyerId,项目发布人ID
     */
    public void notice(Long projectId,String projectName,Long applyerId){
        ZhongBaoTag projectTag = tagService.getTag(0l,projectId);
        Map<String,Object> param = new HashMap<String,Object>();
        param.put("isDeleted",SundayCommonConstants.NO);
        param.put("provinceId",projectTag.getProvinceId());
        param.put("cityId",projectTag.getCityId());
        List<ZhongBaoTag> tags = tagService.list(param);
        //2018年1月18日，避免重复通知到员工 &&tag.getMemberId().longValue()!=applyerId.longValue()
        List<Long> memberIds = new ArrayList<>();
        for(ZhongBaoTag tag:tags){
            if(LongUtil.isNotZreo(tag.getMemberId())){
                memberIds.add(tag.getMemberId());
            }
        }
        if(ListUtil.isNotNull(memberIds)){
            param.clear();
            param.put("id in",memberIds);
            param.put("userType",SundayCommonConstants.user_type_member);
            List<SundayMember> members = memberService.list(param);

            memberIds.clear();
            if(ListUtil.isNotNull(members)){
                List<ZhongBaoTag> newTags=new ArrayList<>();
                for(ZhongBaoTag tag:tags){
                    boolean isMember=false;
                    for(SundayMember member:members){
                        if(LongUtil.isNotZreo(tag.getMemberId())&&tag.getMemberId().longValue()==member.getId()){
                            isMember=true;
                            break;
                        }
                    }
                    if(isMember){
                        newTags.add(tag);
                    }
                }
                for(ZhongBaoTag tag:newTags){
                    logger.info("循环=="+LongUtil.isNotZreo(tag.getMemberId())+"-----"+(tag.getMemberId().longValue()!=applyerId.longValue())+"--id="+tag.getId());
                   // if(LongUtil.isNotZreo(tag.getMemberId())){
                        boolean isMatch=false;
                        //项目标签1
                        if(StringUtils.isNotEmpty(projectTag.getName1())){
                            //匹配人员标签1
                            if(StringUtils.isNotEmpty(tag.getName1())&&tag.getName1().equalsIgnoreCase(projectTag.getName1())){
                                isMatch=true;
                                // continue;
                            }
                            //匹配人员标签2
                            if(StringUtils.isNotEmpty(tag.getName2())&&tag.getName2().equalsIgnoreCase(projectTag.getName1())){
                                isMatch=true;
                                // continue;
                            }
                            //匹配人员标签3
                            if(StringUtils.isNotEmpty(tag.getName3())&&tag.getName3().equalsIgnoreCase(projectTag.getName1())){
                                isMatch=true;
                                // continue;
                            }
                        }
                        //项目标签2
                        if(StringUtils.isNotEmpty(projectTag.getName2())){
                            //匹配人员标签2
                            if(StringUtils.isNotEmpty(tag.getName1())&&tag.getName1().equalsIgnoreCase(projectTag.getName2())){
                                isMatch=true;
                                // continue;
                            }
                            //匹配人员标签2
                            if(StringUtils.isNotEmpty(tag.getName2())&&tag.getName2().equalsIgnoreCase(projectTag.getName2())){
                                isMatch=true;
                                // continue;
                            }
                            //匹配人员标签3
                            if(StringUtils.isNotEmpty(tag.getName3())&&tag.getName3().equalsIgnoreCase(projectTag.getName2())){
                                isMatch=true;
                                //continue;
                            }
                        }
                        //项目标签2
                        if(StringUtils.isNotEmpty(projectTag.getName3())){
                            //匹配人员标签2
                            if(StringUtils.isNotEmpty(tag.getName3())&&tag.getName1().equalsIgnoreCase(projectTag.getName3())){
                                isMatch=true;
                                //continue;
                            }
                            //匹配人员标签2
                            if(StringUtils.isNotEmpty(tag.getName3())&&tag.getName2().equalsIgnoreCase(projectTag.getName3())){
                                isMatch=true;
                                //continue;
                            }
                            //匹配人员标签3
                            if(StringUtils.isNotEmpty(tag.getName3())&&tag.getName3().equalsIgnoreCase(projectTag.getName3())){
                                isMatch=true;
                                //continue;
                            }
                        }
                        logger.info("info-----是否匹配"+isMatch);
                        if(isMatch){
                            //if(LongUtil.)
                            memberIds.add(tag.getMemberId());
                        }
                }
                if(ListUtil.isNotNull(memberIds)){
                    for(Long memberId:memberIds){
                        logger.info("------------------memberId========"+memberId);
                        //2018年1月14日，推送消息
                        messageService.generateMessage(memberId,applyerId,projectId,SundayCommonConstants.zhongbao_message_type_project,projectName+"消息通知",projectName+"消息通知",projectId,null);
                    }
                }











            }else{
                return;
            }
        }else{
            return ;
        }



    }

    /**
     * 通知员工
     * @param projectId
     * @param projectName
     * @param employeeIds
     */
    public void noticeEmployee(Long projectId,String projectName,Long applyerId,List<Long> employeeIds){
     if(ListUtil.isNull(employeeIds))return;
        for(Long memberId:employeeIds){
            //2018年1月14日，推送消息
            messageService.generateMessage(memberId,applyerId,projectId,SundayCommonConstants.zhongbao_message_type_project,projectName+"消息通知",projectName+"消息通知",projectId,null);
        }
    }
}
